package web.struts.action;

import org.apache.struts.action.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import services.ServiceFinder;
import dao.hibernate.Medications;

import java.util.List;

public class ViewMedicationsAction extends Action
{

	 public ActionForward execute(
          ActionMapping mapping,
          ActionForm form,
          HttpServletRequest request,
          HttpServletResponse response) throws Exception
          {

	        //Retrieve the DAO Reference
		  	  dao.SpringHibernateDAO springHibernateDAO = (dao.SpringHibernateDAO) ServiceFinder.getContext(request)
		  		.getBean("springHibernateDao");


      	   List<Medications> list = springHibernateDAO.getMedications();
     		   HttpSession session = request.getSession();
		  		 session.setAttribute("med", list);
           return mapping.findForward("success");
          }
}


